<!DOCTYPE html>
<div id="recycle_file_div">	
		<!-- 查询窗口 -->
		<div class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
           	<div class="modal-dialog" role="document">
                <div class="modal-content">
	                <div class="modal-header">
						<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
						<h4 class="modal-title" id="myModalLabel">查询</h4>
	                </div>
	               	<div class="modal-body">
	            	<!-- 以下为要查询的的内容 -->
	                    <div class="form-group">
	                        <label for="search_fileName">文件名称</label>
	                        <input id="search_fileName" type="text" class="form-control" name="fileName" data-bind="value:queryCondition.fileName" placeholder="文件名称">
	                    </div>
	                    <div class="form-group">
	                        <label for="search_fileUser">上传者</label>
	                        <input id="search_fileUser" type="text" class="form-control" name="fileUser" data-bind="value:queryCondition.fileUser" placeholder="上传者">
	                    </div>
	                <!-- 以上为要查询的内容 -->
					</div>
					<div class="modal-footer">
		                <button type="button" class="btn btn-primary" data-dismiss="modal" data-bind="click:queryClick"><span class="glyphicon glyphicon-search" aria-hidden="true"></span>&nbsp;查询</button>
		                <button type="button" class="btn btn-default" data-dismiss="modal" data-bind="click:clearClick"><span class="glyphicon glyphicon-trash" aria-hidden="true"></span>&nbsp;清空</button>
	            	</div>
                </div>
                
           	</div>
		</div> 
		
		<!-- 工具栏 -->
		<div id="toolbar" class="btn-group">
			<button data-bind="click:deleteClick" type="button"
				class="btn btn-default">
				<span class="glyphicon glyphicon-remove" aria-hidden="true"></span>完全删除
			</button>
			<button  type="button" onclick="restore()"
				class="btn btn-default">
				<span class="glyphicon glyphicon-refresh" aria-hidden="true"></span>还原
			</button>
		</div>
		
		<table id="fileTable" data-bind="bootstrapTable:$root" style="table-layout: fixed;">
			<thead>
				<tr>
					<th data-checkbox="true"></th>
					<th data-field="fileTitle"  class="text-center">文件标题</th>
					<th data-field="uploadsUsername"  	class="text-center">上传人</th>
					<th data-field="delTime"  class="text-center">删除时间</th>
					<th data-field="fileSize"  class="text-center">大小</th>
					<th data-field="fileRemark"  class="text-center">备注</th>
				</tr>
			</thead>
</table>
</div>

<script type="text/javascript">
$(function(){
   		 var data =  {
			    tableParams : {
			    	singleSelect:false,
			    	url : 'recycleFile/page'
		    	},
		    	urls : {
		    		delete : 'recycleFile/delete',
		    		update : 'recycleFile/edit',
		    		add : 'recycleFile/edit',
		    		search:'recycleFile/search'
		    	},
 		    	queryCondition : {
 		    		fileName : '',
 		    		fileUser : ''
		    	}
		};
		ko.applyBindings(new BsTableViewModel(data),document.getElementById('recycle_file_div'));	
});
function restore(){
	var str = $("#fileTable").bootstrapTable('getSelections');
	var idlist = [];
	if(str.length == 0){
		bootbox.alert("请选择一行个文件");
		return ;
	}
	bootbox.confirm("确定要还原这"+str.length+"个文件？", function(s){
		$.each(str,function(index,id){
			idlist.push(id.id);
		});
		$.ajax({
            type: 'POST',
            url: "recycleFile/restore",
            contentType: "application/json;charset=UTF-8",
            data:JSON.stringify({"id":idlist}),
            success: function(data){
            	bootbox.alert({
        			size: "small",
        			title: "提示",
        			message: data.msg, 
        			callback: function(){
        				$("#fileTable").bootstrapTable('refresh');
        			}
        		});
            }
        })
		
	});
	
}

</script>